<!DOCTYPE html>
<html lang="<%= I18n.locale %>" data-controller="<%= controller_name %>" data-action="<%= action_name %>">
<head>
  <% if @stack %>
    <title><%= @stack.repo_name %>/<%= @stack.environment %> - <%= Shipit.app_name %></title>
  <% else %>
  <title><%= Shipit.app_name %></title>
  <% end %>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <%= favicon_link_tag %>
  <%= stylesheet_link_tag :shipit, media: 'all' %>
  <%= javascript_include_tag :shipit %>
  <%= yield :update_subscription %>
  <%= csrf_meta_tags %>

  <%= render 'layouts/head' %>
</head>
<body>
  <% flash.each do |name, msg| %>
    <%= content_tag :div, msg, class: ["flash-#{name}", :flash] %>
  <% end %>

  <div class="banner enable-notifications banner--blue hidden">
    <div class="banner__inner wrapper">
      <div class="banner__content">
        <h2 class="banner__title">Do you want to enable desktop notifications?</h2>
        <div class="banner__accessory">
          <button class="banner__btn btn">Enable notifications</button>
        </div>
      </div>

      <a class="banner__dismiss">&times;</a>
    </div>
  </div>

  <div id="layout-content">
    <% github_status = Shipit::GithubStatus.status
       unless github_status.nil? || github_status[:status] == 'operational' %>
      <div class="banner github-status banner--orange hidden">
        <div class="banner__inner wrapper">
          <div class="banner__content">
            <h2 class="banner__title">GitHub is having issues</h2>
              <% if github_status[:body].present? %>
                "<i><%= github_status[:body] %></i>"
              <% end %>
              <% if github_status[:last_updated].present? %>
                <%= time_ago_in_words(github_status[:last_updated]) %> ago
              <% end %>
          </div>

          <a class="banner__dismiss">&times;</a>
        </div>
      </div>
    <% end %>

    <header class="header">
      <%= link_to "Powered by Shipit v#{Shipit::VERSION}", "https://github.com/Shopify/shipit-engine/tree/v#{Shipit::VERSION}", class: 'powered-by' %>
      <div class="wrapper">
        <div class="header__inner">
          <a href="/" class="logo">
            <span class="visually-hidden"><%= Shipit.app_name %></span>
          </a>
          <div class="header__page-title">
            <%= yield :page_title %>
          </div>
          <% if content_for? :primary_navigation %>
            <div class="header__page-actions">
              <%= yield :primary_navigation %>
            </div>
          <% end %>
        </div>
        <% if content_for? :secondary_navigation %>
          <nav class="nav">
            <%= yield :secondary_navigation %>
          </nav>
        <% end %>
      </div>
    </header>

    <div class="main <%= content_for(:main_classes) %>">
      <%= yield %>
    </div>
  </div>
</body>
</html>
